package cn.iocoder.mall.user.biz.service.impl;

import cn.iocoder.common.utils.common.api.vo.LoginInfo;
import cn.iocoder.common.utils.common.api.vo.Result;
import cn.iocoder.mall.user.biz.dao.AppMessageMapper;
import cn.iocoder.mall.user.biz.dao.MemberMapper;
import cn.iocoder.mall.user.biz.dataobject.AppMessage;
import cn.iocoder.mall.user.biz.dataobject.Feedback;
import cn.iocoder.mall.user.biz.dataobject.Member;
import cn.iocoder.mall.user.biz.service.IMemberService;
import cn.iocoder.mall.user.biz.untils.RedisUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 商城用户
 * @Author: jeecg-boot
 * @Date:   2019-10-18
 * @Version: V1.0
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements IMemberService {

    @Resource
    private MemberMapper mapper;
    @Resource
    private AppMessageMapper messageMapper;

    @Override
    public Boolean modifyFeedBack(Feedback feedback){
        return  mapper.modifyFeedBack(feedback);
    }

    @Override
    public Result login(LoginInfo loginInfo) {
        if (StringUtils.isEmpty(loginInfo.getMobile())||StringUtils.isEmpty(loginInfo.getCode())){
            return Result.error("账号或密码错误");
        }

        return null;
    }

    @Override
    public Member getByMobile(String mobile) {
        return mapper.getOneByMobile(mobile);
    }

    @Override
    public Member getOneByName(String username, String userId) {
        return mapper.getOneByName(userId, username);
    }

    @Override
    public void deleteById(String id) {
        mapper.deleteByUserId(id);
    }

    @Override
    public void deleteByIds(List<String> asList) {
        mapper.deleteByUserIds(asList);
    }

    @Override
    public String getMobileById(String receiver) {
        return mapper.getMobileById(receiver);
    }

    @Override
    public Member getOneUser(String mobile ){
        return mapper.getUser(mobile);
    }
}
